/**
 * AUTHOR: Zhou Yu <pepsior@163.com>
 *
 * COPYRIGHT(C) 2011 Zhou Yu. ALL RIGHTS RESERVED.
 */
#include <windows.h>
#include <xl/patch.h>

/* Patch Count */
#define XL_PATCH_COUNT      sizeof(g_patches) / sizeof(g_patches[0])

/* Patches */
static xl_patch_t g_patches[] = 
{
    {
        {1, 3, 0, 124},
        0x0004450C,
        {0xE8, 0x0E, 0xFF, 0xFF, 0xFF},
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 4, 0, 130},
        0x00044F65,
        {0xE8, 0x0E, 0xFF, 0xFF, 0xFF},
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 4, 2, 146},
        0x00045858,
        {0xE8, 0x0E, 0xFF, 0xFF, 0xFF},
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 4, 3, 156},
        0x000457BD,
        {0xE8, 0x0E, 0xFF, 0xFF, 0xFF},
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 5, 0, 184},
        0x0004BA17,
        {0xE8, 0x0E, 0xFF, 0xFF, 0xFF},
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 5, 0, 200},
        0x0004B986,
        {0xE8, 0x0C, 0xFF, 0xFF, 0xFF},
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 5, 1, 232}, 
        0x0004D61A, 
        {0xE8, 0x0A, 0xFF, 0xFF, 0xFF}, 
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 5, 1, 238}, 
        0x0004D644, 
        {0xE8, 0x0A, 0xFF, 0xFF, 0xFF}, 
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 5, 2, 242}, 
        0x0004D868, 
        {0xE8, 0xF9, 0xFE, 0xFF, 0xFF}, 
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 5, 2, 246}, 
        0x0004D868, 
        {0xE8, 0xF9, 0xFE, 0xFF, 0xFF}, 
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }, 
    {
        {1, 5, 3, 288}, 
        0x0004B8EF, 
        {0xE8, 0xF9, 0xFE, 0xFF, 0xFF}, 
        {0x90, 0x90, 0x90, 0x90, 0x90}
    }
};

xl_patch_t *xl_patch_find(const xl_version_t *version)
{
    size_t i = 0;

    for(i = 0; i < XL_PATCH_COUNT; i++)
    {
        if(xl_version_equal(version, &g_patches[i].version))
        {
            return &g_patches[i];
        }
    }

    return NULL;
}
